import Vue from 'vue'
import Router from 'vue-router'
import store from './store'

import Login from '@/views/login/Login.vue';
import AccountList from '@/views/account/AccountList.vue';
import AccountEdit from '@/views/account/AccountEdit.vue';
import RoleList from '@/views/role/RoleList.vue';
import RoleEdit from '@/views/role/RoleEdit.vue';
import BannerList from '@/views/banner/BannerList.vue';
import BannerEdit from '@/views/banner/BannerEdit.vue';
import TypeList from '@/views/news/TypeList.vue';
import TypeEdit from '@/views/news/TypeEdit.vue';
import NewsList from '@/views/news/NewsList.vue';
import NewsEdit from '@/views/news/NewsEdit.vue';
import UserList from '@/views/user/UserList.vue';
import UserEdit from '@/views/user/UserEdit.vue';
import MapList from '@/views/map/MapList.vue';
import MapEdit from '@/views/map/MapEdit.vue';
import CheckList from '@/views/check/CheckList.vue';
import Menu from '@/views/layout/Menu.vue';
import Home from '@/views/home/home.vue';
import ExtendStandard from '@/views/extendstandard/ExtendStandard.vue';

Vue.use(Router)

//解决重复点击菜单报错的问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export const routes_new=[
    {
       path:'/',
       name:'',
       component:Menu,
       children:[
          {
             path:'home',
             name:'home',
             component:Home,
             meta:{ title:'首页' }
          }
       ]
    },
    {
       path:'/user',
       name:'user',
       component:Menu,
       redirect: '/user/userlist',
       meta: { title:'用户' },
       children:[
          {
              path: 'userlist',
              name: 'userlist',
              component:UserList,
              meta:{ title:'用户中心' }
          },
          {
              path: 'useredit',
              name: 'useredit',
              component:UserEdit,
              meta: { title:'用户编辑' }
          }
       ]
    },
    {
       path:'/news',
       name:'news',
       component:Menu,
       redirect: '/news/newslist',
       meta: { title:'资讯' },
       children: [
            {
                path:'typelist',
                name:'typelist',
                component: TypeList,
                meta:{ title:'咨询分类' }
            },
            {
                path:'typeedit',
                name:'typeedit',
                component: TypeEdit,
                meta:{ title:'咨询分类编辑' }
            },
            {
                path:'newslist',
                name:'newslist',
                component: NewsList,
                meta:{ title:'资讯列表' }
            },
            {
                path:'newsedit',
                name:'newsedit',
                component: NewsEdit,
                meta:{ title:'咨询编辑' }
            },
       ]
    },
    {
        path:'/check',
        name:'check',
        redirect: '/check/checklist',
        component:Menu,
        meta:{ title:'认证' },
        children:[
            {
                path:'checklist',
                name:'checklist',
                component: CheckList,
                meta:{ title:'认证列表' }
            }
        ]
    },
    {
        path:'/map',
        name:'map',
        redirect: '/map/maplist',
        component:Menu,
        meta:{ title:'地图' },
        children:[
            {
                path:'maplist',
                name:'maplist',
                component: MapList,
                meta:{ title:'地址列表' }
            },
            {
                path:'mapedit',
                name:'mapedit',
                component: MapEdit,
                meta:{ title:'地址编辑' }
            }
        ]
    },
    {
        path:'/system',
        name:'system',
        redirect: '/system/accountlist',
        component:Menu,
        meta:{ title:'系统设置' },
        children:[
            {
                path:'accountlist',
                name:'accountlist',
                component: AccountList,
                meta:{ title:'用户列表' }
            },
            {
                path:'accountEdit',
                name:'accountEdit',
                component: AccountEdit,
                meta:{ title:'用户编辑' }
            },
            {
                path:'rolelist',
                name:'rolelist',
                component: RoleList,
                meta:{ title:'角色列表' }
            },
            {
                path:'roleedit',
                name:'roleedit',
                component: RoleEdit,
                meta:{ title:'角色编辑' }
            },
            //banner列表
            {
                path:'bannerlist',
                name:'bannerlist',
                component: BannerList,
                meta:{ title:'横幅列表' }
            },
            {
                path:'banneredit',
                name:'banneredit',
                component: BannerEdit,
                meta:{ title:'横幅编辑' }
            },
            {
                path:'extendstandard',
                name:'extendstandard',
                component: ExtendStandard,
                meta:{ title:'金额发放标准' }
            }
        ]
    },
    {
        path:'/login',
        name:'login',
        component:Login
    }
];

export default  new Router({
    //嵌套路由，设置布局
    //mode: 'history',
    routes:routes_new
})
